package main

import (
	"fmt"
)

type Printer interface {
	PrintFile(file string)
}

type Epson struct {
}

type Hp struct {
}

func (Epson) PrintFile(file string) {
	fmt.Println("使用爱普生打印机打印文件：", file)
}

func (Hp) PrintFile(file string) {
	fmt.Println("使用惠普打印机打印文件：", file)
}

type Computer interface {
	Print(file string)
	SetPrinter(printer Printer)
}

type Mac struct {
	printer Printer
}

type Windows struct {
	printer Printer
}

func (m *Mac) Print(file string) {
	m.printer.PrintFile(file)
}

func (m *Mac) SetPrinter(printer Printer) {
	m.printer = printer
}

func (m *Windows) Print(file string) {
	m.printer.PrintFile(file)
}

func (m *Windows) SetPrinter(printer Printer) {
	m.printer = printer
}

func main() {
	mac := &Mac{}
	mac.SetPrinter(&Hp{})
	mac.printer.PrintFile("简历文档1")

	Windows := &Windows{}
	Windows.SetPrinter(&Epson{})
	Windows.printer.PrintFile("简历文档2")
}
